Global variable declaration inside function (Python

If you only want to read (access) the value of a global variable, you do not need the global keyword. Python automatically looks up the variable in the global scope if it doesn't find it locally. However, the global keyword is mandatory if you want to modify (write to) that variable. Here is the breakdown of why it exists. 1. Reading (No global needed) As you noticed, this works fine. Python looks for count locally, fails, looks globally, and finds it. code Pythondownloadcontent_copyexpand_less count = 10 def read_variable():…

Why the load of main by _start uses got entry, not adrp+add pair?

The _start function uses a Global Offset Table (GOT) entry to load the address of main primarily because _start is defined in a pre-compiled object file (typically Scrt1.o) that was built with Position-Independent Code (PIC) enabled. Here is the detailed explanation of why this happens and why adrp + add isn't used by default: 1. _start is Pre-Compiled Generic Code The _start function is not compiled at the same time as your application's main.c. It is part of the C Runtime (CRT) startup files (specifically Scrt1.o for Position…

AArch64 Pre/Post Indexing

In AArch64 (ARMv8-A 64-bit architecture), Pre-indexing and Post-indexing are memory addressing modes used with Load (LDR) and Store (STR) instructions. Their primary purpose is to perform Writeback: they automatically update the base register (the pointer) with a new address as part of the instruction execution. This is extremely efficient for iterating through arrays or managing stacks because it eliminates the need for a separate ADD or SUB instruction to move the pointer. Here is the breakdown of how they work. 1. Pre-Indexed Addressing Syntax: [base, #offset]!Key Symbol: The…

Check whether an executable is pure C or CPP

Distinguishing between a pure C and a C++ executable can be achieved by examining the symbols and library dependencies of the binary file. C++ compilers employ a technique called "name mangling" to support function overloading and namespaces, which is absent in C. Furthermore, C++ programs have a distinct set of standard library dependencies. Inspecting Symbol Tables for Name Mangling A primary indicator of C++ code is the presence of "mangled" names in the executable's symbol table. C++ compilers alter function and variable names to encode information about their…

Setup Docker on Ubuntu 25.10

To set up Docker on Ubuntu 25.10 (Questing Quokka), follow these steps. These instructions use the official Docker repository to ensure you get the latest version. Step 1: Uninstall Old Versions Conflicting packages (like docker.io or podman-docker) might be installed by default. Remove them to prevent conflicts: sudo apt-get remove docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc Step 2: Set Up the Docker Repository 1、Update your package index and install necessary dependencies: sudo apt-get update sudo apt-get install ca-certificates curl 2、Add Docker’s official GPG key: sudo install -m 0755 -d /etc/apt/keyrings sudo curl…

PIE Relocation: Tagging Addresses

In a Position-Independent Executable (PIE), absolute addresses aren't "tagged" directly within the machine code. Instead, the linker creates a separate list of instructions and data locations that need fixing, and this list is stored in a special section of the binary called the relocation table. The dynamic loader uses this table at runtime to patch the code with the correct memory addresses once the binary's actual location in memory is known. The Core Mechanism: Linker and Loader Teamwork 🤝 Think of it like moving into a new apartment building. You…

Understanding Binary File Components

Symbol Table Think of the symbol table as a directory for the "named things" within your code, like functions and global variables. When you compile a source file, the compiler creates an object file. This object file contains the machine code for your functions and space for your global variables, but it doesn't yet know the final memory addresses of everything. The symbol table maps these symbolic names (e.g., my_function, global_variable) to their locations within the object file. This is vital for the linker, the tool that combines multiple object files and libraries…

Control Dependence Graph and Data Dependence Graph

A Control Dependence Graph (CDG) and a Data Dependence Graph (DDG) are essential tools in computer science, particularly in compiler design and program analysis. They represent the dependencies between different parts of a program's code, but they focus on two distinct types of relationships. Control Dependence Graph (CDG) A Control Dependence Graph illustrates how the execution of a statement is controlled by a conditional branching statement. In simpler terms, a statement is control-dependent on a conditional if the outcome of that conditional determines whether the statement will be executed. Nodes in a CDG represent the…

WordPress site Migration from CentOS7 to Ubuntu24

Phase 1: Preparation on CentOS 7 (Source Server) First, you need to back up your data. Log in to your CentOS server via SSH. 1、Backup the DatabaseRun this command to export your database to a SQL file.(Replace db_name, db_user with your actual database details) mysqldump -u db_user -p db_name > wordpress_backup.sql 2、Backup WordPress FilesCompress your website files into a single archive to make the transfer easier.(Assuming your site is at /var/www/html or /usr/share/nginx/html) tar -czf wordpress_files.tar.gz /var/www/html Phase 2: Setup Ubuntu 24.04 (Destination Server) Log in to your new Ubuntu 24.04 server. You need…

How to reset ZeroTier moon node

ZeroTier Installation ZeroTier provides a script that detects your OS, adds the correct GPG keys and repositories, and installs the package for you. # Install curl (if missing): sudo apt update && sudo apt install curl -y # Run the install script: curl -s https://install.zerotier.com | sudo bash # Check Status: sudo zerotier-cli status # Enable on Boot: sudo systemctl enable zerotier-one Deorbit obsolete Moon Node To check if your client is connected to a Moon node and to remove it ("de-orbit"), follow these steps. sudo zerotier-cli listpeers…